﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        // 递归 函数自调用
        function run(num) {
            // console.log("run",num);
            if (num == 0) return 0;
            return run(num - 1) + num;
        }

        console.log(run(5));

         // function a(){
         //    console.log("===");
         //    b()
         //    console.log("aaaa");
         //}
         //function b(){
         //    console.log("bbbb");
         //}

         //a()


        var data1 = [{
            title: "biaot",
            arr: ["a", "b", "c"],
            obj: {
                name: "aaa",
                arr1: ["aaa", "bbb", "ccc"]
            }
        }, {
            title: "标题2",
            arr: ["2a", "3b", "4c"],
            obj: {
                name: "222aaa",
                arr1: ["2aaa", "2bbb", "2ccc"]
            }
        }, {
            title: "标题23",
            arr: ["3a", "3b", "3c"],
            obj: {
                name: "333aaa",
                arr1: ["3aaa", "3bbb", "3ccc"]
            }
        }]

        //var obj = {
        //    name: "333aaa",
        //    arr1: ["3aaa", "3bbb", "3ccc"]
        //}
        // 递归的深拷贝
        function clone(data) {
            if (typeof data != "object") return data;

            var yinyong = data instanceof Array ? [] : {};
            for (var key in data) {
                // data[key] //如果是基本数据类型,直接赋值 如果不是,需要再次循环
                yinyong[key] = clone(data[key]);
            }
            return yinyong;
        }
        var aaa = clone(data1);
        console.log(aaa);

        // aaa[2].obj.name = "lili";
        // console.log(aaa);

        // console.log(data1); 
    </script>
</body>
</html>